package lucid.hrms.management.race;

import java.io.Serializable;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("raceService")
public class RaceServiceImpl implements RaceService, Serializable {
	private static final Logger logger = LoggerFactory
			.getLogger(RaceServiceImpl.class);

	private static final long serialVersionUID = 1L;

	@Autowired
	private RaceRepository raceRepository;

	@Transactional(propagation = Propagation.REQUIRED)
	public Race saveRace(Race race) {
		return raceRepository.merge(race);
	}

	@Transactional(readOnly = true)
	public List<Race> findRaces(RaceCriteria raceCriteria, int firstResult,
			int maxResults) {
		logger.debug("raceCriteria: " + raceCriteria);
		logger.debug("raceRepository: " + raceRepository);
		logger.debug("firstResult: " + firstResult);
		logger.debug("maxResults: " + maxResults);

		return raceRepository.findRaces(raceCriteria, firstResult, maxResults);
	}

	public int findTotalRaces() {
		// TODO Auto-generated method stub
		return 10;
	}
}